package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Instrument;
import com.example.Laboratory.Service.InstrumentService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@RestController
@Api(value = "Instrument", description = "实验室概况设备仪器")
@RequestMapping(value = "/instrument")
@CrossOrigin
public class InstrumentController {

    @Autowired
    InstrumentService instrumentService;

    @ApiOperation(value = "添加设备仪器", notes = "添加设备仪器")
    @RequestMapping(value = "/addInstrument", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addInstrument (Instrument t) throws IOException {
        return ResultCode.SUCCESS.result(instrumentService.addInstrument(t));
    }

    @ApiOperation(value = "删除设备仪器", notes = "删除设备仪器")
    @RequestMapping(value = "/deleteInstrument", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteInstrument (@RequestParam int instrument_id) throws IOException {
        return ResultCode.SUCCESS.result(instrumentService.deleteInstrument(instrument_id));
    }

    @ApiOperation(value = "查找设备仪器通过全表", notes = "查找设备仪器全表")
    @RequestMapping(value = "/researchInstrumentAll", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectInstrumentAll ( ) throws IOException {
        return ResultCode.SUCCESS.result(instrumentService.selectInstrumentAll());
    }

    @ApiOperation(value = "修改设备仪器", notes = "修改设备仪器")
    @RequestMapping(value = "/reviseInstrument", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateInstrument (Instrument i) throws IOException {
        return ResultCode.SUCCESS.result(instrumentService.updateInstrument(i));
    }
}
